package com.yanze.customviewdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.yanze.customviewdemo.widget.ActivityProvider;
import com.yanze.customviewdemo.widget.TaijiView;

public class TaijiActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityProvider.saveActivity(this);
        final TaijiView taijiView = new TaijiView(this);
        setContentView(taijiView);
        Handler handler = new Handler() {
            private float degrees = 0;

            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                degrees += 5;
                degrees = degrees > 360 ? 0 : degrees;
                taijiView.setDegrees(degrees);
                sendEmptyMessageDelayed(0, 80);
            }
        };
        handler.sendEmptyMessageDelayed(0, 100);

    }

    public static void start(Context context) {
        context.startActivity(new Intent(context, TaijiActivity.class));
    }
}
